﻿using DeepEarth.Map.Core;
using System.Windows.Data;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using DeepEarth.Core;
namespace DeepEarth.Toolkit.Common.Converters
{
    public class FirstLocationConverter : IValueConverter
    {
        public static FirstLocationConverter Instance = new FirstLocationConverter();

        public static Location Convert(IEnumerable<Location> locations)
        {
            return locations.FirstOrDefault();
        }

        public static ObservableCollection<Location> ConvertBack(Location value)
        {
            return new ObservableCollection<Location> { value };
        }

        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Convert((IEnumerable<Location>)value);
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return ConvertBack((Location)value);
        }
    }
}
